import {fetchHighlightReq,} from "../apis/highlightApi";
import {handleResp,} from "../utils/commonfunc";

export const highlight = {

    state: {
        articles: [],
    },

    reducers: {

        setHighlightList(state, payload) {
            return {
                ...state,
                articles: payload,
            }
        }

    },

    effects: (dispatch) => ({
        async doFetchHighlightList(payload, rootState) {
            const resp = await fetchHighlightReq(payload)
            handleResp(resp, dispatch, (data) => {
                dispatch.highlight.setHighlightList(data.articles)
            })
        },
    })

}
